package top.lcm889.nowcoder.top;


/**
 * @author Coder-lcm
 * @date 2021/2/24
 */
public class NC78_反转链表 {

    public ListNode ReverseList(ListNode head) {
        ListNode res = new ListNode(-1);
        while (head != null && head.next != null) {
            ListNode next = head.next;
            head.next = res.next;
            res.next = head;
            head = next;
        }
        return res.next;
    }

    public static void main(String[] args) {

    }

}
